<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录</title>
<script type="text/javascript" src="${basePath }js/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
	//进行ajax异步请求处理
	function doAjaxGet(){

			var url = "../../AjaxDemoServlet";
			
			//post方法传输数据的data
			var datas = "un="+document.getElementById("adminName").value
			+"&upsw="+document.getElementById("adminPsw").value;
			$.ajax({
				//请求类型
				type:"POST",
				//服务器url
				url:url,
				//发送的数据
				data:datas,
				//成功之后回调方法，方法的参数是服务器响应的内容也就是ajax引擎获取到responseText内容
				success: function(respText){
					$("#msg").html(respText);
				}
			});
	}
	//jquery中ajax的doGet方法
	function doGet(){

		var url = "../../AjaxDemoServlet";
		
		//post方法传输数据的data
		var datas = {"un":document.getElementById("adminName").value,
		"upsw":document.getElementById("adminPsw").value};
		$.get(url,datas,function(respText){
				$("#msg").html(respText);
		},"text");
}
	function doGet2(){

		var url = "../../AjaxDemoServlet";
		
		var datas = '{"un":"'+document.getElementById('adminName').value
        +'","upsw":"'+document.getElementById('adminPsw').value+'"}';
		$.get(url,eval("("+datas+")"),function(respText){
				$("#msg").html(respText);
		},"text");
}
</script>
</head>
<body>
<div>
	用户名：<input type="text" id="adminName" />
	密码：<input type="password" id="adminPsw" />
	<input type="button" name="" value="login" onclick="doGet2();"/>
	</div>
	<div>
	<p id="msg" style="color: black;">登录成功！</p>
	</div>
</body>
</html>